package com.线程和进程;

public class MyThreadDemo1 {
    public static void main(String[] args) {
        MyThread mt1 = new MyThread();
        MyThread mt2 = new MyThread();
        mt1.setName("关羽");
        mt2.setName("张飞");
        //设置主线程为刘备
        Thread.currentThread().setName("刘备");
        //设置关羽张飞为刘备的守护线程，即不求同年同月同日生，但求同年同月同日死
        mt1.setDaemon(true);
        mt2.setDaemon(true);
        /*void setDaemon(boolean on) 将此线程标记为 daemon线程或用户线程 */

        mt1.start();
        mt2.start();

        for (int i=0;i<10;i++){
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}
